package nl.RvdW.TVgids;

import java.util.ArrayList;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ListView;

public class ChannelFragment extends ListFragment {
	//private Button b;
	private ChannelAdapter lv1_content;
	private ArrayList<Programme> programs;

	public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

		programs = new ArrayList<Programme>();
		lv1_content = new ChannelAdapter(getActivity(), android.R.layout.simple_list_item_1,
				programs);
		setListAdapter(lv1_content);
	}
	
	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		Programme p = Global.db.getProgramme(v.getId());
		if(p!=null){
			Global.showProgramme(p);
		}
	}
	
	@Override
	public void onResume() {
		super.onResume();
		Global.db.fetchChannel(programs, getArguments().getString("id"));
	}
}